import {defineConfig, loadEnv} from 'vite'
import react from '@vitejs/plugin-react'
import vitePluginImp from 'vite-plugin-imp'
// https://vitejs.dev/config/

export default ({ mode }) => {
    const VITE_ENV = loadEnv(mode, process.cwd());
    return defineConfig({
        plugins: [
            react(),
            vitePluginImp({
                libList:[
                    {
                        libName:'antd',
                        style:(name)=>`antd/es/${name}/style`
                    }
                ]
            }),
        ],
        server: {
            host: '0.0.0.0',
            proxy: {
                '/api': {
                    target: VITE_ENV.VITE_BASE_URL,
                    changeOrigin: true,
                    rewrite: (path) => path.replace(/^\/api/, '') // 不可以省略rewrite
                }
            }
        },
    })
}